package org.apache.commons.graph.visitor

import com.gitee.wsl.func.consumer.Consumer

interface ITargetVertexVisitor<V> {
    fun getTargetVertexes(vertex: V): Collection<V>

    fun hasOutwardEdge(vertex: V): Boolean {
        return !getTargetVertexes(vertex).isEmpty()
    }

    fun forEachTarget(source: V, action: Consumer<in V>) {
        val list = getTargetVertexes(source)
        for (target in list) {
            action.accept(target)
        }
    }
}